class Solution(object):
    def twoSum(self, numbers, target):
        """
        :type numbers: List[int]
        :type target: int
        :rtype: List[int]
        """
        dictDiff = {}  # 用字典记录一个另一个加数与其序号的map，通过空间换取时间，只需要一次遍历
        for (i, val) in enumerate(numbers):
            diff = target - val
            if diff in dictDiff:
                return [dictDiff[diff] + 1, i + 1]

            dictDiff[val] = i


s = Solution()
print(s.twoSum([2, 7, 11, 15], 9))
